package com.ruoyi.xh.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TablePageDataInfo;
import com.ruoyi.common.core.domain.CommentResult;
import com.ruoyi.xh.domain.XhAdminSock;
import com.ruoyi.xh.service.IXhAdminSockService;

/**
 * socketController
 *
 * @author songjw
 * @date 2024-12-13
 */
@Api(tags = "socketController",value = "socketController")
@RestController
@RequestMapping("/xh/adminSock")
public class XhAdminSockController extends BaseController {

    @Autowired
    private IXhAdminSockService xhAdminSockService;

    /**
     * 查询socket列表
     */
    @PreAuthorize("@ss.hasPermi('xh:adminSock:list')")
    @GetMapping("/list")
    @ApiOperation("查询socket列表")
    public TablePageDataInfo<XhAdminSock> list(XhAdminSock xhAdminSock) {
        return TablePageDataInfo.success(xhAdminSockService.selectXhAdminSockList(xhAdminSock));
    }

    /**
     * 获取socket详细信息
     */
    @PreAuthorize("@ss.hasPermi('xh:adminSock:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取socket详细信息")
    public CommentResult<XhAdminSock> getInfo(@PathVariable("id") Long id) {
        return CommentResult.success(xhAdminSockService.selectXhAdminSockById(id));
    }

    /**
     * 新增socket
     */
    @PreAuthorize("@ss.hasPermi('xh:adminSock:add')")
    @Log(title = "socket", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增socket")
    public CommentResult<XhAdminSock> add(@RequestBody XhAdminSock xhAdminSock) {
            xhAdminSockService.insertXhAdminSock(xhAdminSock);
        return CommentResult.success();
    }

    /**
     * 修改socket
     */
    @PreAuthorize("@ss.hasPermi('xh:adminSock:edit')")
    @Log(title = "socket", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改socket")
    public CommentResult<XhAdminSock> edit(@RequestBody XhAdminSock xhAdminSock) {
            xhAdminSockService.updateXhAdminSock(xhAdminSock);
        return CommentResult.success();
    }

    /**
     * 删除socket
     */
    @PreAuthorize("@ss.hasPermi('xh:adminSock:remove')")
    @Log(title = "socket", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation("删除socket")
    public CommentResult<XhAdminSock> remove(@PathVariable Long[] ids) {
            xhAdminSockService.deleteXhAdminSockByIds(ids);
        return CommentResult.success();
    }
}
